﻿using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace WPFExcelReport
{ 
    public partial class YCCVA02 : DocumentBase
    { 
        
        VYCCVA02 vm;
        public YCCVA02()
        {
            this.Name = "工艺管理";
            vm = new VYCCVA02();
            DataContext = vm;
            InitializeComponent(); 
            txtUserID.Text = vm.app.User;
            txtPassword.Password =vm.app.Pwd; 
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        { 
            try
            {
                if (DesignerProperties.GetIsInDesignMode(this))
                    return;
                if (IsLoaded)
                    return;
                IsLoaded = true; 
              }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return;

        }
        private void btnLogIn_Click(object sender, RoutedEventArgs e)
        {
            string Mandant = txtMANDANT.Text.ToUpper();
            string userID = Helpers.Helper.Left(txtUserID.Text.ToUpper() + "        ", 8);
            System.Security.SecureString SPassword = txtPassword.SecurePassword;
            IntPtr p = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(SPassword);
            string Password = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(p);
            DataRow dwHR = vm.app.UserValid(userID, Password);
            if (dwHR == null)
            {
                MessageBox.Show("请检查登陆信息");
                return;
            }
            txtLogIn.Background = new SolidColorBrush(Colors.Green);
            expLog.IsExpanded = false;
            expLog.Visibility = Visibility.Collapsed;
        } 
    }
}
